# encoding: utf-8
__author__ = 'binbin'
__date__ = '2018/10/18 0013 08:47'


from goods.models import Goods

from django.views.generic.base import View

class GoodsListView(View):
    def get(self,request):
        '''商品列表业'''
        json_list = []
        goods = Goods.objects.all()[:10]

        from django.forms.models import model_to_dict
        for good in goods:
            json_dict = model_to_dict(good)
            json_list.append(json_dict)
        import json
        from django.core import serializers
        json_data = serializers.serialize('json',goods)
        json_data = json.loads(json_data)
        from django.http import HttpResponse,JsonResponse

        return JsonResponse(json_data,safe=False)
